import java.util.List;
import java.util.Scanner;


class ListNode {
    public int val;
    public ListNode next;
    public ListNode(int val) {
        this.val = val;
        this.next = null;
    }
}

public class Test03 {
    // 反转部分 单链表
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String[] list = sc.nextLine().trim().split(" ");
        ListNode head = new ListNode(Integer.parseInt(list[0]));
        ListNode cur = head;
        for (int i = 1; i < n; i++) {
            cur.next = new ListNode(Integer.parseInt(list[i]));
            cur = cur.next;
        }

        String[] params = sc.nextLine().split(" ");
        int from = Integer.parseInt(params[0]);
        int to = Integer.parseInt(params[1]);

        head = reversePartLinkedList(head, from, to);

        while(head != null) {
            System.out.print(head.val + " ");
            head = head.next;
        }
    }

    private static ListNode reversePartLinkedList(ListNode head, int from, int to) {
        ListNode dummy = new ListNode(-1);
        dummy.next = head;
        ListNode pre = dummy;
        for (int i = 0; i < from - 1; i++) {
            pre = pre.next;
        }
        ListNode cur = pre.next;
        for (int i = from; i < to; i++) {
            ListNode curNext = cur.next;
            cur.next = curNext.next;
            curNext.next = pre.next;
            pre.next = curNext;
        }
        return dummy.next;
    }
}
